<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class Admin_Form_Member_AddCourse extends RedCross_Form
{
  public function init()
  {
        $today = new RedCross_Date ();

        $this->addElement('select', 'course', array(
            'required'    =>  true,
            'label'       =>  'Kurs',
        ));

        $this->getElement('course')->addMultiOption(null, '-- Velg kurs --');

        $this->addElement('hidden', 'submit_addcourse');

 		$this->addElement('text', 'course_date', array(
			'filters' => array('StringTrim'),
			'validators' => array(
				array('Date', true),
			),
			'required' => true,
			'label' => 'Kursdato:',
            'value' => $today->getDateStr()
		));

        $this->addElement('submit', 'submit', array(
            'required' => true,
            'ignore'   => true,
            'label'    => 'Legg til',
        ));

  }

    public function fillForm($member_id)
    {
        $service = RedCross_Factory::getService('Core_Service_Course');
        $courses = $service->fetchAllCourses();

        $courseElement = $this->getElement('course');
        foreach($courses as $course)
        {
            $courseElement->addMultiOption($course->id, $course->name);
        }
    }

}
